﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using GameCore;

namespace GameObject
{
    public class VisibleGameObject
    {
        public Sprite[] _sprite;
        // thong so x dai dien cho sprite can hien thi
        // y dai dien cho texture trong sprite can hien thi
        public List<Vector2> _lsprite;
        public int _nsprite;
        private float _x;
       
        public float X
        {
            get { return _x; }
            set
            {
                _x = value;
            }
        }
        private float _y;

        public float Y
        {
            get { return _y; }
            set
            {
                _y = value;
            }
        }
        private int _w;

        public int Width
        {
            get { return _w; }
            set { _w = value; }
        }
        private int _h;

        public int Height
        {
            get { return _h; }
            set { _h = value; }
        }
        
        
        public virtual VisibleGameObject Clone()
        {
            return new VisibleGameObject();
        }

        public virtual void Update(GameTime gameTime)
        {
            this.Update(gameTime, this.X, this.Y, this.Width, this.Height);
        }

        public virtual void Update(GameTime gameTime,float x, float y, int w, int h)
        {
            for (int i = 0; i < _lsprite.Count; i++)
            {
                if (_lsprite[i].X < _sprite.Count<Sprite>())
                {
                    _sprite[(int)_lsprite[i].X].Update(gameTime,(int) _lsprite[i].Y, x, y, w, h);
                }
            }
        }

        public virtual void Draw(GameTime gameTime,SpriteBatch spriteBatch)
        {
            for (int i = 0; i < _lsprite.Count; i++)
            {
                if (_lsprite[i].X < _sprite.Count<Sprite>())
                {
                    _sprite[(int)_lsprite[i].X].Draw(gameTime,spriteBatch);
                }
            }
        }
      
    }
}
